<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>预约编辑</title>
    <link rel="stylesheet" th:href="@{/pear/component/pear/css/pear.css}"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">会议主题</label>
                <div class="layui-input-block">
                    <input type="text" name="purpose" lay-verify="required|purpose" autocomplete="off"
                           placeholder="请输入会议主题"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">预约用户</label>
                <div class="layui-input-inline">
                    <select name="username" id="username" lay-filter="username">
                        <option value="-1">请选择</option>
                        <!-- 动态加载会议室选项 -->
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn  layui-btn-sm" lay-submit=""
                    lay-filter="reservation-edit">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script th:src="@{/pear/component/layui/layui.js}"></script>
<script th:src="@{/pear/component/pear/pear.js}"></script>
<script th:inline="javascript">

    layui.use(['form', 'jquery'], function () {
        let baseURL = /*[[@{/}]]*/ '';
        let form = layui.form;
        let layer = layui.layer;
        let $ = layui.$;
        form.on('submit(reservation-edit)', function (data) {

            data.field.reservationId = parent.reservationId
            data.field.userId = data.field.username
            console.log(data.field)
            $.ajax({
                url: baseURL + 'meeting/reservation/update',
                data: data.field,
                dataType: 'json',
                type: 'post',
                success: function (result) {
                    if (result.code === 1000) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 2000
                        }, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("myReservation-table");
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 2000
                        }, function () {
                            parent.layui.table.reload("myReservation-table");
                        });
                    }
                }
            })
            return false;
        });
    });
</script>
</body>
</html>